package com.example.film.mapper;

import com.example.film.entity.CinemaSell;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Date;
import java.util.List;

@Mapper
public interface CinemaSellMapper {
    //影院每日票房table-->cinemasell
    //查看影院每日票房信息
    @Select("select rank,cinemaName,box_office,province,city,cinemaSession,people,avg_price,\n" +
            "dayNum,avg_people,currentDate from cinemasell")
    List<CinemaSell> findCinemaSell();

    //分页查询影院每日票房信息
    @Select("select rank,cinemaName,box_office,province,city,cinemaSession,people,avg_price,\n" +
            "dayNum,avg_people,currentDate from cinemasell LIMIT #{pageSize} OFFSET #{startIndex}")
    List<CinemaSell> findCinemaSellInfo(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    //根据时间分页显示当日影院票房信息
    @Select("select rank,cinemaName,box_office,province,city,cinemaSession,people,avg_price,\n" +
            "dayNum,avg_people,currentDate from cinemasell where currentDate=#{currentDate} LIMIT #{pageSize} OFFSET #{startIndex}")
    List<CinemaSell> findCinemaSellByDate(@Param("currentDate") Date currentDate, @Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    //根据省市分页显示当日影院票房信息
    @Select("select rank,cinemaName,box_office,province,city,cinemaSession,people,avg_price,dayNum,avg_people,currentDate from cinemasell\n" +
            "where province=#{province} LIMIT #{pageSize} OFFSET #{startIndex}")
    List<CinemaSell> findCinemaSellByProvince(@Param("province") String province, @Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize);

    //根据省市对影院每日票房、场次、人次求和信息(按照日期查找)
    @Select("select province, totalSell, totalSession, totalPeople, currentdate from cinemadaysellsum where currentdate=#{currentDate}")
    List<CinemaSell> findDaySumInfo(Date currentDate);
}
